package com.example.evanproject.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.evanproject.domain.Courselesson;
import com.example.evanproject.domain.Exampaper;
import com.example.evanproject.domain.Questions;
import com.example.evanproject.service.impl.CourselessonServiceImpl;
import com.example.evanproject.service.impl.ExampaperServiceImpl;
import com.example.evanproject.service.impl.QuestionsServiceImpl;
import com.example.evanproject.util.AjaxResult;
import com.example.evanproject.vo.PaperVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

//新建试卷
@RestController
@RequestMapping("example")
@CrossOrigin
public class ExampaperController {
//    新建课程
@Autowired
private ExampaperServiceImpl exampaperService;
@Autowired
private QuestionsServiceImpl questionsService;
@Autowired
private CourselessonServiceImpl courselessonService;

    @PostMapping("addpaper")
    public AjaxResult addpaperList(@RequestBody Exampaper exampaper){

//        更改某个课程的详情
        Integer num=exampaperService.saveList(exampaper);
        Courselesson courselesson=new Courselesson();
        courselesson.setLsHomework(String.valueOf(exampaper.getId()));
        courselesson.setLsWay(3);
        courselesson.setLsId(exampaper.getLesson());
        courselessonService.updateById(courselesson);
      return  AjaxResult.success(num);
    }

//    查询某个试卷的详细信息
     @RequestMapping("selectExampaperById")
    public AjaxResult selectExampaperById(Integer exampaperId){
        return  AjaxResult.success(exampaperService.selectExampaperById(exampaperId));
    }

//提交试卷

    @PostMapping("submitPaper")
    public AjaxResult submitPaper(@RequestBody  PaperVo paperVo){

        return  AjaxResult.success(exampaperService.submitPaper(paperVo));
    }



}
